import { ProductID, XBusinesslineId } from '..'
import { ECouponType, PromotionType } from '../enum'

/**订单优惠券获取参数 */
export type OrderCouponParam = {
  app_id: 1 //1
  product_info: Array<{ product_id: string; price: string }> //[{ product_id: '1398768'; price: '10' }]
  best_price?: number // 1
  choose_user_coupons?: Array<{
    /**sss   */
    category: number //1
    user_coupon_id: string //'2M3Q443CBY4SE3XH6XTC'
  }>
  'X-Businessline-Id': XBusinesslineId
}

/**商品信息*/
export type CouponProduct = {
  product_id: ProductID //1398768
  product_name: string //'【测试课】一年级数学春下10'
  subject_name: string // '数学'
  price: string //'10'
  reduced_money: string // '0'
  product_coupon_list: []
}
/**------------订单类 */
export type OrderCouponAllocationInfo = {
  product_id: ProductID //1398768
  product_name: string //'【测试课】一年级数学春下10'
  subject_name: string //'数学'
  reduced_money: string //'9'
}
/**订单优惠券数据*/
export type OrderCoupon = {
  coupon_name: string //'测试奖学金订单类'
  batch_id: number //4625687
  user_coupon_id: string //'2M3Q443CBY4SE3XH6XTC'
  category: ECouponType //订单券
  discount_type: 1 //折扣类型
  discount: string //'9'
  threshold_text: string //'满10可用'
  valid_stime: string //'2023-02-27 00:00:00'
  valid_etime: string //'2024-02-23 23:59:59'
  is_checked: boolean // true  可选择
  is_valid: boolean //  true    验证通过
  invalid_reason: string //''暂不可与已选优惠券叠加使用
  category_desc: string //'订单类'
}
export type CashCoupon = OrderCoupon

/**------------------------------ */
export type AllocationInfo = {
  product_id: ProductID //1398768
  product_name: string //'【测试课】一年级数学春下10'
  subject_name: string //'数学'
  reduced_money: string //'9'
}
export type CouponDetail = {
  promotion_type: PromotionType //PromotionType.COUPON_ORDER_CATE_ID
  coupon_name: string //'测试奖学金订单类'
  reduced_money: string //'9'
  /**分配信息 */
  allocation_info: Array<AllocationInfo>
}
/**优惠券总信息 */
export type OrderCouponInfo = {
  total_reduced_money: string // '9'
  /**商品列表 */
  product_list: Array<CouponProduct>
  /**订单类 */
  order_coupon_reduced_money: string //  '9'
  order_coupon_allocation_info: Array<OrderCouponAllocationInfo>
  order_coupon_list: Array<OrderCoupon>
  /**------------------- */

  /**现金类 */
  cash_coupon_reduced_money: string // '0'
  cash_coupon_allocation_info: []
  cash_coupon_list: Array<CashCoupon>
  /**-------------------- */
  is_recommend: false
  rule_url: string //  'https://h5.xiwang.com/61e93e065bb54c63000fdade.html'
  checked_coupon_num: number // 1
  valid_coupon_num: number // 1
  total_discount: string //  '9'
  checked_product_coupon_num: number // 0
  valid_product_coupon_num: number // 0
  product_coupon_reduced_money: number //0
  /** */
  checked_order_coupon_num: number //1
  valid_order_coupon_num: number // 1
  checked_cash_coupon_num: number //0
  valid_cash_coupon_num: number //0
  coupon_detail: Array<CouponDetail>
}

// const aa = {
//   result: {
//     status: 1,
//     data: {
//       total_reduced_money: '9',
//       product_list: [
//         {
//           product_id: 1398768,
//           product_name: '【测试课】一年级数学春下10',
//           subject_name: '数学',
//           price: '10',
//           reduced_money: '0',
//           product_coupon_list: [],
//         },
//       ],
//       order_coupon_reduced_money: '9',
//       order_coupon_allocation_info: [
//         {
//           product_id: 1398768,
//           product_name: '【测试课】一年级数学春下10',
//           subject_name: '数学',
//           reduced_money: '9',
//         },
//       ],
//       order_coupon_list: [
//         {
//           coupon_name: '测试奖学金订单类',
//           batch_id: 4625687,
//           user_coupon_id: '2M3Q443CBY4SE3XH6XTC',
//           category: 1,
//           discount_type: 1,
//           discount: '9',
//           threshold_text: '满10可用',
//           valid_stime: '2023-02-27 00:00:00',
//           valid_etime: '2024-02-23 23:59:59',
//           is_checked: true,
//           is_valid: true,
//           invalid_reason: '',
//           category_desc: '订单类',
//         },
//         {
//           coupon_name: '测试奖学金订单类',
//           batch_id: 4625687,
//           user_coupon_id: '2M3Q443CBY4SE4MBXH88',
//           category: 1,
//           discount_type: 1,
//           discount: '9',
//           threshold_text: '满10可用',
//           valid_stime: '2023-02-27 00:00:00',
//           valid_etime: '2024-02-23 23:59:59',
//           is_checked: false,
//           is_valid: false,
//           invalid_reason: '暂不可与已选优惠券叠加使用',
//           category_desc: '订单类',
//         },
//         {
//           coupon_name: '测试奖学金订单类',
//           batch_id: 4625687,
//           user_coupon_id: '2M3Q443CBY4SEKMDPWX2',
//           category: 1,
//           discount_type: 1,
//           discount: '9',
//           threshold_text: '满10可用',
//           valid_stime: '2023-02-27 00:00:00',
//           valid_etime: '2024-02-23 23:59:59',
//           is_checked: false,
//           is_valid: false,
//           invalid_reason: '暂不可与已选优惠券叠加使用',
//           category_desc: '订单类',
//         },
//       ],
//       cash_coupon_reduced_money: '0',
//       cash_coupon_allocation_info: [],
//       cash_coupon_list: [],
//       is_recommend: false,
//       rule_url: 'https://h5.xiwang.com/61e93e065bb54c63000fdade.html',
//       checked_coupon_num: 1,
//       valid_coupon_num: 1,
//       total_discount: '9',
//       checked_product_coupon_num: 0,
//       valid_product_coupon_num: 0,
//       product_coupon_reduced_money: 0,
//       checked_order_coupon_num: 1,
//       valid_order_coupon_num: 1,
//       checked_cash_coupon_num: 0,
//       valid_cash_coupon_num: 0,
//       coupon_detail: [
//         {
//           promotion_type: 1201,
//           coupon_name: '测试奖学金订单类',
//           reduced_money: '9',
//           allocation_info: [
//             {
//               product_id: 1398768,
//               product_name: '【测试课】一年级数学春下10',
//               subject_name: '数学',
//               reduced_money: '9',
//             },
//           ],
//         },
//       ],
//     },
//     trace_id: 'dayu_97b72393e88538e6a2cfdd458e2e1cf4',
//   },
// }
